/*
 * Copyright (c) 2019. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package cn.dyw.player;

import javazoom.jl.decoder.JavaLayerException;

/**
 * 单例模式创建播放器
 */
public class PlayerFactory {

    private static Player player;

    private PlayerFactory() {
    }

    public static Player factory() {
        if (player == null) {
            synchronized (PlayerFactory.class) {
                if (player == null) {
                    try {
                        player = new Player();
                    } catch (JavaLayerException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return player;
    }
}
